package com.jinrui.swing.widget;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;

public class TreeItemPanel extends JPanel {
	JLabel lblImage,lblName;
	/**
	 * Create the panel.
	 */
	public TreeItemPanel(boolean isSelect,boolean isFocus) {
		setBackground(Color.WHITE);	
		setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
		this.setBorder(new EmptyBorder(0, 0, 0, 0));
		
		lblImage = new JLabel();
		lblImage.setPreferredSize(new Dimension(24,24));
		add(lblImage);		
		
		JPanel panel = new JPanel();
		panel.setBackground(Color.WHITE);
		add(panel);
		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
		lblName = new JLabel("ABC");		
		panel.add(lblName);
		panel.setBorder(new EmptyBorder(1, 1, 1, 1));
		if(isFocus||isSelect)
		{
			panel.setBackground(new Color(184, 207, 229));
			panel.setBorder(new LineBorder(new Color(99, 130, 191)));
			
//			lblName.setForeground(Color.WHITE);
		}
	}
	
	public void setIcon(String iconPath)
	{
		ScaleIcon sIcon = new ScaleIcon(new ImageIcon(iconPath));
		lblImage.setIcon(sIcon);
	}
	public void setText(String text)
	{
		lblName.setText(text);
	}
}
